﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net.Sockets;
using System.Text;

namespace Memceched
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            s.Connect("59.151.102.126", 11211);
            //创建bytes字节数组以转换发送串 
            byte[] bytesSendStr = new byte[1024];
            //将发送内容字符串转换成字节byte数组 
            bytesSendStr = Encoding.ASCII.GetBytes("stats\r\n");
            s.Send(bytesSendStr, bytesSendStr.Length, 0);
            string recvStr = "";
            //返回实际接收内容的字节数 
            int bytes = 1024;
            //声明字节数组，一次接收数据的长度为1024字节 
            byte[] recvBytes = new byte[bytes];
            //循环读取，直到接收完所有数据 
            s.Receive(recvBytes, recvBytes.Length, 0);
            recvStr += Encoding.ASCII.GetString(recvBytes, 0, bytes);
            Response.Write(recvStr);
        }
    }
}
